package cn.jasonone.config;

import javax.annotation.Resource;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import cn.jasonone.interceptors.AuthorityInterceptor;
import cn.jasonone.interceptors.LoginInterceptor;

@Configuration
public class WebConfig implements WebMvcConfigurer {
	@Resource
	private LoginInterceptor loginInterceptor;
	@Resource
	private AuthorityInterceptor authorityInterceptor;

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		InterceptorRegistration loginInterceptor = registry.addInterceptor(this.loginInterceptor);
		loginInterceptor.addPathPatterns("/**").excludePathPatterns("/login","/logout");
		InterceptorRegistration authorityInterceptor = registry.addInterceptor(this.authorityInterceptor);
		authorityInterceptor
			.addPathPatterns("/**")
			.excludePathPatterns("/login","/logout","/**/*.js","/layui/**","/modules/**","/**/*.js","/error");
	}

}
